package com.wn.production.web;

import com.wn.common.PageBean;
import com.wn.common.ResponseEntity;
import com.wn.entity.MeasuringDevice;
import com.wn.production.service.MeasuringDeviceService;
import com.wn.production.vo.MeasuringDeviceVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/production/mdc")
@Slf4j
@Validated
public class MeasuringDeviceController {
    @Autowired
    private MeasuringDeviceService measuringDeviceService;
    @RequestMapping("add")
    public ResponseEntity add(@Validated MeasuringDevice measuringDevice) {
        measuringDeviceService.insert(measuringDevice);
        return ResponseEntity.success;
    }

    @RequestMapping("getByCondition")
    public ResponseEntity getByCondition(@RequestBody MeasuringDeviceVo measuringDeviceVo) {
        PageBean<MeasuringDevice> pageBean = measuringDeviceService.getByCondition(measuringDeviceVo);
        return new ResponseEntity(pageBean);
    }
    @RequestMapping("update")
    public ResponseEntity update(@RequestBody @Validated MeasuringDevice measuringDevice){
        measuringDeviceService.update(measuringDevice);
        return ResponseEntity.success;
    }
}
